home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0635.ZIP / WIDGIT.PAS < prev    next >
Pascal/Delphi Source File  |  1987-09-01  |  6KB  |  166 lines

  1. Program WidgitProg(Input,Output);
  2. {  8/30/87 :   Data entry and screen handling are the strong suits of MiniGen.
  3.              This program demonstrates the use of MiniGen generated procedures
  4.              to get a program up and running quickly. After setting up the
  5.              background color and clearing the screen, call the procedure you
  6.              created with the MiniGen screen painter to display the main
  7.              screen. Calls to EnterData() will gather your data which can then
  8.              be written to a file or processed however you choose.
  9.                While the structure of this program is quite simple, it does a
  10.              lot for you. A better way to gather your data would be to use a
  11.              case structure when calling EnterData(). The case selector should
  12.              be a byte variable, while the case labels represent input fields
  13.              numbered top to bottom, left to right on the screen. Hitting
  14.              return or the tab key ( --> ), should take the user to the next
  15.              field. Conversely, the back tab key ( <-- ), should take the user
  16.              to the previous field. By embedding the case statement in a
  17.              Repeat/Until loop and initializing the case selector to one,
  18.              you can use the return code of EnderData to increment or
  19.              decrement the case selector at the bottom of the loop. That will
  20.              take you up and down the screen.
  21.                In future versions of MiniGen, this data entry procedure will
  22.              be automated, making the promise of full data entry application
  23.              generation a reality. Until then, this program architecture should
  24.              be easy to create, allowing you to turn out data entry programs
  25.              in a couple of hours (once you get the hang of it), as I did with
  26.              this one.
  27.  
  28.       Minigen Products
  29.       Eric H. Snyder
  30.       1417 Evergreen
  31.       Homewood, IL  60430
  32. }
  33. Const
  34.   ScreenCount = 1;       { Enter the number of screens you wish to define }
  35.  
  36. {$I MGPROG.INC}          { Combined windowing and data entry routines }
  37. {$I WIDGIT.INC}          { Screen procedure developed with MiniGen }
  38. {$I GETDATE.INC}         { Retrieve system date }
  39. {$I GETTIME.INC}         { Retrieve system time }
  40.  
  41.                          { Enter any ScrnGen window procedres here }
  42.  
  43. Var
  44.   ReturnCode  : Integer;
  45.   Continue    : Char;
  46.   Name        : String[25];
  47.   Addr1,Addr2 : String[30];
  48.   City        : String[12];
  49.   State       : String[2];
  50.   Zip         : String[5];
  51.   SSN1        : String[3];
  52.   SSN2        : String[2];
  53.   SSN3        : String[4];
  54.   Cash,Check,
  55.   Charge      : Char;
  56.   Each,Box,
  57.   _Case       : Char;
  58.   Quantity    : Integer;
  59.   Discount    : Integer;
  60.   Price       : Real;
  61.   Extension   : Real;
  62.  
  63. Type
  64.   CharSet = Set of Char;
  65.  
  66. Function GetChar(Var CharIn:Char;XLoc,YLoc:Integer;
  67.                      GoodChars,CharExits:Charset) : Integer;
  68. Var
  69.   Ch : Char;
  70. Begin
  71. GotoXY(Xloc,YLoc);
  72. Repeat
  73.   Read(kbd,Ch);
  74. Until (Ch in (GoodChars + CharExits));
  75. If Ch in GoodChars then
  76.   Begin
  77.   CharIn := Ch;
  78.   Write(Ch);
  79.   End;
  80. GetChar := 0;
  81. If Ch in CharExits then
  82.   GetChar := Ord(Ch);
  83. End; {GetChar}
  84.  
  85. Procedure MainLoop;      { Main program logic }
  86. Begin
  87. TextBackground(Blue);
  88. Continue := 'Y';
  89. Repeat
  90.   ClrScr;
  91.   WidgitOEScreen;
  92.   Rite(CurrentDate,7,1,20);
  93.   Rite(CurrentTime,71,1,20);
  94.   {**}
  95.   Name       := '';
  96.   Addr1      := '';
  97.   Addr2      := '';
  98.   City       := '';
  99.   State      := '';
  100.   Zip        := '';
  101.   SSN1       := '';
  102.   SSN2       := '';
  103.   SSN3       := '';
  104.   Cash       := ' ';
  105.   Check      := ' ';
  106.   Charge     := ' ';
  107.   Each       := ' ';
  108.   Box        := ' ';
  109.   _Case      := ' ';
  110.   Quantity   := 1;
  111.   Discount   := 0;
  112.   Price      := 0.0;
  113.   {**}
  114.   ReturnCode := EnterData(Name, 'S',22, 7,25,0,78,$87,[27]);
  115.   ReturnCode := EnterData(Addr1,'S',22, 8,30,0,78,$87,[27]);
  116.   ReturnCode := EnterData(Addr2,'S',22, 9,30,0,78,$87,[27]);
  117.   ReturnCode := EnterData(City, 'S',22,10,12,0,78,$87,[27]);
  118.   ReturnCode := EnterData(State,'U',36,10, 2,0,78,$87,[27]);
  119.   ReturnCode := EnterData(Zip,  'N',40,10, 5,0,78,$87,[27]);
  120.   ReturnCode := EnterData(SSN1, 'N',22,12, 3,0,95,$87,[27]);
  121.   ReturnCode := EnterData(SSN2, 'N',26,12, 2,0,95,$87,[27]);
  122.   ReturnCode := EnterData(SSN3, 'N',29,12, 4,0,95,$87,[27]);
  123.   {
  124.        EnterData() does not perform controlled I/O on Character data, so you
  125.      may need to write a little routine like GetChar(), or use this one.
  126.      The routine should be a function returning an integer, have a VAR
  127.      variable which will receive the entered character, and be able to tell
  128.      the difference between good data and an exit key.
  129.   }
  130.   ReturnCode := GetChar(Cash,  28,16,['X','x'],[#27]);
  131.   ReturnCode := GetChar(Check, 38,16,['X','x'],[#27]);
  132.   ReturnCode := GetChar(Charge,49,16,['X','x'],[#27]);
  133.   ReturnCode := GetChar(Each,  28,17,['X','x'],[#27]);
  134.   ReturnCode := GetChar(Box,   36,17,['X','x'],[#27]);
  135.   ReturnCode := GetChar(_Case, 45,17,['X','x'],[#27]);
  136.   GotoXY(1,1);
  137.   LowerInt   := 1;
  138.   UpperInt   := 144;
  139.   ReturnCode := EnterData(Quantity, 'I',22,18,6,0,80,$87,[27]);
  140.   LowerReal  := 0.50;
  141.   UpperReal  := 100.00;
  142.   ReturnCode := EnterData(Price,'R',38,18,6,2,80,$87,[27]);
  143.   LowerInt   := 0;
  144.   UpperInt   := 100;
  145.   ReturnCode := EnterData(Discount, 'I',22,19,2,0,80,$87,[27]);
  146.   Extension  := (Price * ((100 - Discount) / 100)) * Quantity;
  147.   GotoXY(22,20);
  148.   Write(Extension:8:2);
  149.   {**}
  150.   GotoXY(1,25);
  151.   Write('Again ? (Y/N) ');
  152.   Read(kbd,Continue);
  153.   Continue := Upcase(Continue);
  154. Until Continue = 'N';
  155. End;
  156.  
  157. Begin
  158. ClrScr;
  159. MaxLimits;
  160. InitializeScreens;
  161.                         {** No screens defined in this demo **}
  162. MainLoop;
  163. TerminateScreens;
  164. TextBackground(Black);
  165. ClrScr;
  166. End.